package com.hc.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hc.domain.DictItem;
import com.hc.dto.ListDictItemDTO;
import com.hc.mapper.DictItemMapper;
import com.hc.service.DictItemService;
import com.hc.vo.DictItemVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 字典
 *
 * @author 梁云亮
 */
@Service
public class DictItemServiceImpl extends ServiceImpl<DictItemMapper, DictItem> implements DictItemService {
    @Resource
    private DictItemMapper dictItemMapper;

    @Override
    public int createDictItem(DictItemVO dictItemVO) {
        int res = dictItemMapper.insertDictItem(dictItemVO);
        return res;
    }

    @Override
    public int batchInsertDictItem(List<DictItemVO> list) {
        int res = baseMapper.batchInsertDictItem(list);
        return res;
    }

    @Override
    public int deleteDictItemById(Integer id) {
        int res = dictItemMapper.deleteDictItemById(id);
        return res;
    }

    @Override
    public int batchDeleteDictItemsById(List<Integer> ids) {
        int res = dictItemMapper.batchDeleteDictItemsById(ids);
        return res;
    }

    @Override
    public boolean getDictItemByName(String name) {
        boolean res = dictItemMapper.selectDictItemByName(name) == 1 ? true : false;
        return res;
    }

    @Override
    public List<ListDictItemDTO> listDictItemByTypeId(Integer typeId) {
        List<ListDictItemDTO> res = dictItemMapper.selectDictItemByTypeId(typeId);
        return res;
    }

    @Override
    public int modifyDictItem(Integer id, DictItemVO dictItemVO) {
        int res = dictItemMapper.updateDictItemSelective(id, dictItemVO);
        return res;
    }

    @Override
    public int modifyDictItemStatus(Integer id, Integer status) {
        int res = dictItemMapper.updateDictItemStatus(id, status);
        return res;
    }

    @Override
    public int modifyDictItemLevel(Integer id, Integer level) {
        int res = dictItemMapper.updateDictItemLevel(id, level);
        return res;
    }
}
